﻿using System.ComponentModel;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace dsconvert
{
    [DefaultProperty("DataSourceID")]
    [ToolboxData("<{0}:treeds runat=server></{0}:treeds >")]

    public class treeds : HierarchicalDataSourceControl
    {






        protected override HierarchicalDataSourceView GetHierarchicalView(string viewPath)
        {
            /* DataView myd = (DataView)(DataSourceID as SqlDataSource).Select(DataSourceSelectArguments.Empty);
             //throw new System.NotImplementedException();
         SqlHierarchicalEnumerable data =  new SqlHierarchicalEnumerable();;
             */
            SqlDataSource sdt = Page.FindControl(DataSourceID.ToString()) as SqlDataSource;
            HierarchicalDataSourceView hdm = new SqlHierarchicalDataSourceView(sdt, viewPath, parentid, datatid);
            return hdm;
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Bindable(true)]
        [Description("请输入页面上的sql控件id")]
        [Category("工具按钮属性设置")]
        [IDReferenceProperty(typeof(DataSourceControl))]
        [Browsable(true)]
        public string DataSourceID
        {
            get
            {
                string obj2 = this.ViewState["DataSourceID"] as string;

                return (string)obj2;


            }
            set
            {

                this.ViewState["DataSourceID"] = value;
                //   this.OnDataPropertyChanged();
            }
        }
         [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Bindable(true)]
        [Description("请输入绑定到数据源的父节点id")]
        [Category("工具按钮属性设置")]
     [Browsable(true)]
        public string parentid
        {
            get
            {
                string obj23 = this.ViewState["pid"] as string;

                return (string)obj23;


            }
            set
            {

                this.ViewState["pid"] = value;
                //   this.OnDataPropertyChanged();
            }
        }
         [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
         [Bindable(true)]
         [Description("请输入绑定到数据源的节点id")]
         [Category("工具按钮属性设置")]
        [Browsable(true)]
         public string datatid
         {
             get
             {
                 string obj234 = this.ViewState["datatid"] as string;

                 return (string)obj234;


             }
             set
             {

                 this.ViewState["datatid"] = value;
                 //   this.OnDataPropertyChanged();
             }
         }
        //   private object _dataSource;
    }
}
